package cn.com.zaprk.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * @PackageName: cn.com.zaprk.jdbc
 * @ClassName: JDBC_03
 * @Description:
 * @author: RZS
 * @date: 2021/10/20  17:20
 */
public class JDBC_03 {
    public static void main(String[] args) throws SQLException {
        // 注册驱动
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        // 获取连接
        Connection connection = DriverManager.getConnection("jdbc:mysql:///mydb1", "root", "root");
        // 创建sql执行对象 Statement
        Statement statement = connection.createStatement();
        // 编写sql语句
        String sql = "create table student(id int)";
        // 执行sql
        statement.execute(sql);
        // 关闭连接
        statement.close();
        connection.close();

    }
}
